package com.usoft.thrift.example.contact.server;

import com.usoft.thrift.example.ContactService;
import com.usoft.thrift.example.contact.ContactServiceImpl;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TServer.Args;
import org.apache.thrift.server.TSimpleServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;

/**
 * @author: Lenovo(2015 - 07 - 15 18 : 58)
 */
public class ThriftServer {

    public static void main(String args[]) throws TTransportException {

        TServerSocket serverSocket = new TServerSocket(8111);

        ContactService.Processor<ContactService.Iface> processor = new ContactService.Processor<ContactService.Iface>(new ContactServiceImpl());
        TCompactProtocol.Factory factory = new TCompactProtocol.Factory();
        Args ag = new Args(serverSocket);
        ag.protocolFactory(factory);
        ag.processor(processor);
        TServer server = new TSimpleServer(ag);
        System.out.println("start server...");
        server.serve();
    }
}
